/**
 * Created by zjy on 16-2-25.
 */
var mongodb = require('./mongodb').db;
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var locationSchema = new Schema({
    stu_number: String,
    location_x: String,
    location_y: String,
    msg: String,
    create_at: { type : Date, default: Date.now },
    update_at: { type : Date},
    delete_at: { type : Date}
});
var locationModel = mongodb.model("gw_location", locationSchema);
var locationDAO = function(){};

locationDAO.prototype.save = function(data) {
    var instance = new locationModel(data);
    return instance.save();
};

locationDAO.prototype.findAll = function(t_no) {
    return locationModel.find({ stu_number: t_no});
};

locationDAO.prototype.update = function (_id, data) {
    data.update_at = new Date();
    return locationModel.update({"_id":_id},data);
};

module.exports = new locationDAO();